package gtug.duesseldorf.client.model;

import java.io.Serializable;

public class ClientLoginData implements Serializable {

	private static final long serialVersionUID = 1L;
	private String m_server;
	private String m_user;

	public ClientLoginData(String server, String user) {
		m_server = server;
		m_user = user;
	}

	/**
	 * private constructor for serialization
	 */
	@SuppressWarnings("unused")
	private ClientLoginData() {
	}

	public String getServer() {
		return m_server;
	}

	public void setServer(String server) {
		m_server = server;
	}

	public String getUser() {
		return m_user;
	}

	public void setUser(String user) {
		m_user = user;
	}

	@Override
	public String toString() {
		StringBuffer buf = new StringBuffer("Server: ").append(m_server).append(" User:").append(m_user);

		return buf.toString();
	}

	public String getDomain() {
		String user = getUser();
		if (user == null) {
			return null;
		}

		String[] split = user.split("@");
		if (split.length == 2) {
			return split[1];
		} else {
			return null;
		}
	}

}
